# packcc-objcg

This is a objdump output parser created using packcc parser tool

This is used to generate a callgraph of a binary file

Compile a test program with symbols like this

gcc -g -O0 test.c -o test

Create a assembly listing using objdump like this

objdump -d -j .text --demangle=auto --show-raw-insn test >out.txt

To create a callgraph

cat out.txt |./objcg

To see all possible binary formats objdump supports use

objdump --help

This is used with x86_64 elf binary on Linux

For other type of binary formats the objdump command must be different

For other type of binary formats the peg file must be edited

Then generate new parser using

packcc objcg.peg

The peg scans for funtion start which look like this

0000000000001b4a <sfg_init>:

The peg scans for function call which look like this

    1418:	e8 2d 07 00 00       	callq  1b4a <sfg_init>

This is a indirect call

    2eb3:	ff d0                	callq  *%rax

This is a call to glibc

    1104:	ff 15 d6 de 00 00    	callq  *0xded6(%rip)        # efe0 <__libc_start_main@GLIBC_2.2.5>

This is a call to a external library function

    4140:	e8 3b cf ff ff       	callq  1080 <calloc@plt>

When the binary is stripped with strip -s only the calls to lib routines are available
